<?php
/*
 * @Author: lokei
 * @Date: 2023-01-03 00:59:37
 * @LastEditors: lokei
 * @LastEditTime: 2023-01-03 01:05:49
 * @Description: 
 */
namespace App\Http\Controllers\Widget;

use App\Common\Tools\ResultTool;
use App\Http\Controllers\Controller;
use App\Models\Widget\NavPicModel;
use Illuminate\Http\Request;

class NavPicController extends Controller {
    public function get(Request $request) {
        $nav_pic = NavPicModel::where('mode', '=', $request->input('mode'))->first();
        if(is_null($nav_pic)) {
            $nav_pic = new NavPicModel();
            $nav_pic->mode = $request->input('mode');
            $nav_pic->save();
        }
        $res = ResultTool::success();
        $res['data']['nav_pic'] = $nav_pic;
        return $res;
    }

    public function update(Request $request) {
        $nav_pic = NavPicModel::where('mode', '=', $request->input('mode'))->first();
        $nav_pic->img = $request->input('img');
        $nav_pic->path = $request->input('path');
        $nav_pic->display = $request->input('display');
        $nav_pic->save();
        return ResultTool::success();
    }
}